package com.saihai.jiankang.ufZhgl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.saihai.common.annotation.Log;
import com.saihai.common.core.controller.BaseController;
import com.saihai.common.core.domain.AjaxResult;
import com.saihai.common.enums.BusinessType;
import com.saihai.jiankang.ufZhgl.domain.UfZhgl;
import com.saihai.jiankang.ufZhgl.service.IUfZhglService;
import com.saihai.common.utils.poi.ExcelUtil;
import com.saihai.common.core.page.TableDataInfo;

/**
 * 后台账号Controller
 * 
 * @author ruoyi
 * @date 2024-07-08
 */
@RestController
@RequestMapping("/jiankang/ufZhgl")
public class UfZhglController extends BaseController
{
    @Autowired
    private IUfZhglService ufZhglService;

    /**
     * 查询后台账号列表
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhgl:list')")
    @GetMapping("/list")
    public TableDataInfo list(UfZhgl ufZhgl)
    {
        startPage();
        List<UfZhgl> list = ufZhglService.selectUfZhglList(ufZhgl);
        return getDataTable(list);
    }

    /**
     * 导出后台账号列表
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhgl:export')")
    @Log(title = "后台账号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UfZhgl ufZhgl)
    {
        List<UfZhgl> list = ufZhglService.selectUfZhglList(ufZhgl);
        ExcelUtil<UfZhgl> util = new ExcelUtil<UfZhgl>(UfZhgl.class);
        util.exportExcel(response, list, "后台账号数据");
    }

    /**
     * 获取后台账号详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhgl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ufZhglService.selectUfZhglById(id));
    }

    /**
     * 新增后台账号
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhgl:add')")
    @Log(title = "后台账号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UfZhgl ufZhgl)
    {
        return toAjax(ufZhglService.insertUfZhgl(ufZhgl));
    }

    /**
     * 修改后台账号
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhgl:edit')")
    @Log(title = "后台账号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UfZhgl ufZhgl)
    {
        return toAjax(ufZhglService.updateUfZhgl(ufZhgl));
    }

    /**
     * 删除后台账号
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhgl:remove')")
    @Log(title = "后台账号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ufZhglService.deleteUfZhglByIds(ids));
    }
}
